package com.iwayin.web.common;

import com.iwayin.core.dataobject.UserDO;


/**
 * 登录用户缓存
 * @author xiaobo.feng<xiaobo.feng@foxmail.com>
 *
 * 2011-8-9
 */
public class ThreadLocalManager {
	
	private static final ThreadLocal<UserDO> manager = new ThreadLocal<UserDO>();
	
	
	public static void setLoginUser(UserDO user){
		UserDO old = getLoginUser();
		if(old != null){
			clear();
		}
		manager.set(user);
	}
	
	public static UserDO getLoginUser() {
		return manager.get();
	}

	public static void clear() {
		manager.remove();
	}

}
